package com.nut.service.brand;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.nut.dao.BrandMapper;
import com.nut.pojo.Brand;
import com.nut.pojo.BrandExample;

/**
 * @author Nut
 * @version 2018年8月7日 下午2:21:15
 * @TODO
 *
 */
@Service
public class BrandServiceImpl implements BrandServiceI {

	@Resource
	BrandMapper brandMapper;

	@Override
	public int add(Brand brand) {
		return brandMapper.insertSelective(brand);
	}

	@Override
	public List<Brand> query(Brand brand, BrandExample example) {
		if (brand.getWithPage() == 1) {
			PageHelper.startPage(brand.getPageNo(), brand.getPageSize());
		}
		return brandMapper.selectByExample(example);
	}

	@Override
	public int del(int id) {

		return brandMapper.deleteByPrimaryKey(id);
	}

	@Override
	public Brand seleteOne(int id) {
		
		return brandMapper.selectByPrimaryKey(id);
	}

	@Override
	public int update(Brand brand) {
		
		return brandMapper.updateByPrimaryKeySelective(brand);
	}

}
